<template>
	<view>
		<view class="main">
			<u-subsection :list="list" :current="curNow" @change="sectionChange" active-color="#ff9900"></u-subsection>
			<view class="order-list">
				<view class="order-item" v-for="item in selectOrder">
					<view class="top">
						<text>{{item.orderTypeName}}</text>
						<view class="status">{{item.orderStatus}}</view>
					</view>
					<view class="bottom">
						<text>订单号：{{item.orderNo}}</text>
						<text>订单生成日期：{{item.createTime}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [
					{
						name: '未付款',
					},
					{
						name: '已付款',
					}
				],
				curNow: 0,
				orderList: [],
				selectOrder: [],
				flag: false
			};
		},
		onLoad() {
			this.getOrder()
		},
		methods: {
			sectionChange(index){
				this.curNow = index
				this.getSelect()
			},
			getOrder(){
				this.$request({
					url: '/prod-api/api/allorder/list'
				}).then(res => {
					this.orderList = res.rows
					console.log(this.orderList)
					this.getSelect()
			})
			},
			getSelect(){
				if(this.curNow === 0){
					this.selectOrder = this.orderList.filter(item => item.orderStatus.includes('待' || '未'))
					console.log(this.selectOrder)
				}else{
					this.selectOrder = this.orderList.filter(item => item.orderStatus.includes('已'))
					console.log(this.selectOrder)
				}
			}
		}
		// computed: {
		// 	getSelect(){
		// 		if(this.curNow === 0){
		// 			return this.orderList.filter(item => item.orderStatus.includes('待' || '未'))
		// 			console.log(this.selectOrder)
		// 		}else{
		// 			return this.orderList.filter(item => item.orderStatus.includes('已'))
		// 			console.log(this.selectOrder)
		// 		}
		// 	}
		// }
	}
</script>

<style lang="scss">
	page{
		background-color: #f7f7f7;
		.main{
			.order-list{
				display: flex;
				flex-direction: column;
				padding: 20rpx;
				.order-item{
					background-color: #fff;
					margin-top: 20rpx;
					padding: 20rpx;
					border-radius: 20rpx;
					.top{
						display: flex;
						flex-direction: row;
						justify-content: space-between;
						padding: 20rpx 0;
						border-bottom: 4rpx solid #e4e7ed;
						align-items: center;
						text{
							color: #2979ff;
							font-size: 32rpx;
							font-weight: bold;
						}
						.status{
							color: white;
							background-color: #dd6161;
							width: 120rpx;
							height: 60rpx;
							display: flex;
							justify-content: center;
							align-items: center;
							border-radius: 10rpx;
						}
					}
					.bottom{
						display: flex;
						flex-direction: column;
						text{
							margin-top: 20rpx;
							font-size: 28rpx;
						}
					}
					&:first-child{
						margin-top: 0;
					}
				}
			}
		}
	}
</style>